﻿using System.Collections.Generic;
using System.Diagnostics;

namespace HQS.TokenInterpolation
{
    public class ParserResult<T>
    {
        private readonly List<string> _errors = new List<string>();

        public ParserResult(T result)
        {
            Output = result;
        }

        public T Output { get; private set; }

        public double ParsingTime { get; private set; }

        public bool HasErrors
        {
            get { return _errors.Count > 0; }
        }

        public IEnumerable<string> ErrorMessages
        {
            get { return _errors; }
        }

        public void SetParsingTime(Stopwatch watch)
        {
            watch.Stop();
            ParsingTime = watch.ElapsedTicks/(double) Stopwatch.Frequency;
            ParsingTime *= 1000;
        }

        public void AddErrorMessage(string message)
        {
            _errors.Add(message);
        }
    }
}